package com.hongmeng.web.controller.operater;

import java.util.List;

import com.hongmeng.operater.domain.LeaveMessage;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.hongmeng.common.annotation.Log;
import com.hongmeng.common.core.controller.BaseController;
import com.hongmeng.common.core.domain.AjaxResult;
import com.hongmeng.common.enums.BusinessType;
import com.hongmeng.operater.domain.HmLeaveMessage;
import com.hongmeng.operater.service.IHmLeaveMessageService;
import com.hongmeng.common.utils.poi.ExcelUtil;
import com.hongmeng.common.core.page.TableDataInfo;

/**
 * 留言Controller
 *
 * 
 * @author hongmeng
 * @date 2021-01-21
 */
@ApiOperation("留言管理")
@RestController
@RequestMapping("/operater/leaveMessage")
public class HmLeaveMessageController extends BaseController
{
    @Autowired
    private IHmLeaveMessageService hmLeaveMessageService;

    /**
     * 查询留言列表
     */
    @ApiOperation("查询留言列表")
    @PreAuthorize("@ss.hasPermi('operater:leaveMessage:list')")
    @GetMapping("/list")
    public TableDataInfo list(LeaveMessage hmLeaveMessage)
    {
        startPage();
        List<HmLeaveMessage> list = hmLeaveMessageService.selectHmLeaveMessageList(hmLeaveMessage);
        return getDataTable(list);
    }

    /**
     * 获取留言详细信息
     */
    @PreAuthorize("@ss.hasPermi('operater:leaveMessage:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return AjaxResult.success(hmLeaveMessageService.selectHmLeaveMessageById(id));
    }

    /**
     * 修改留言
     */
    @PreAuthorize("@ss.hasPermi('operater:leaveMessage:edit')")
    @Log(title = "留言", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HmLeaveMessage hmLeaveMessage)
    {
        return toAjax(hmLeaveMessageService.updateHmLeaveMessage(hmLeaveMessage));
    }

    /**
     * 删除留言
     */
    @PreAuthorize("@ss.hasPermi('operater:leaveMessage:remove')")
    @Log(title = "留言", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(hmLeaveMessageService.deleteHmLeaveMessageByIds(ids));
    }
}
